package com.transcoachapp.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.transcoachapp.R;
import com.transcoachapp.data.BusStationTime;

public class StationTimeAdapter extends ArrayAdapter<BusStationTime> {
	private Activity context;
	private ArrayList<BusStationTime> items;
	
	public StationTimeAdapter(Context context, int textViewResourceId,
			ArrayList<BusStationTime> objects) { 
		super(context, textViewResourceId, objects);
		this.items = objects;
		this.context = (Activity) context;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		if (this.items != null)
		      return this.items.size();
		return 0;
	}
	@Override
	public BusStationTime getItem(int arg0) {
		// TODO Auto-generated method stub
		return this.items.get(arg0);
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{   // Ordinary view in Spinner, we use android.R.layout.simple_spinner_item
		
		final BusStationTime bs  = getItem(position);
		View bsdRow = context.getLayoutInflater().inflate(R.layout.ferry_line, null);
        TextView textView2 = (TextView) bsdRow.findViewById(R.id.ferryName);
        textView2.setText(bs.getStationTime().toString().substring(0, 5));
		return bsdRow;
	}
}
